$(function(){
    var mySwiper = new Swiper('#banner_con',{
        calculateHeight : true,
        pagination : '#banner_pag',
        loop : true
    });
    $("#banner_con1").swiper({
        calculateHeight : true,
        slidesPerView: 'auto'
    });
    $("#banner_con2").swiper({
        calculateHeight : true,
        slidesPerView: 'auto'
    });
    $("#add").click(function(){
        $(".add_shop").load("addCart.html",function(){
            $("#pro_btn").hide();
            $("#shop_btn,.add_shop,.pro_fix_bg").show();

            $("#banner_con3").swiper({
                freeMode : true,
                calculateHeight : true,
                slidesPerView: 'auto'
            });
            $("#banner_con4").swiper({
                freeMode : true,
                calculateHeight : true,
                slidesPerView: 'auto'
            });

            $("#banner_con3 .sh_color").click(function(){
                $("#banner_con3 .change").removeClass("change");
                var t = $(this),
                    bg = t.attr("bg"),
                    pic = t.find("img").attr("src");
                t.addClass("change");
                $(".shop_pic img").attr("src",pic);
                $(".change_co_si .cart_color img").attr("src",bg);
            });
            $("#banner_con4 .sh_size").click(function(){
                $("#banner_con4 .change").removeClass("change");
                var t = $(this),
                    txt = t.text();
                t.addClass("change");
                $(".change_size span").text(txt);
            });
        });
    });

    $("#chance").click(function(){
        $("#shop_btn,.add_shop,.pro_fix_bg").hide();
        $("#pro_btn").show();
    });

    $("#sure").click(function(){
        $("#shop_btn,#add,.add_shop,.pro_fix_bg").hide();
        $("#pro_btn,#settle,.add_tip").show();
        $(".add_tip").animate({bottom:130},function(){
            $(this).fadeOut();
        });
    });

    $(".pro_size a").click(function(){
        $(".pro_size a.change_txt").removeClass("change_txt");
        $(this).addClass("change_txt");
    });

    $(".pro_min a").click(function(){
        $(".pro_min a.change").removeClass("change");
        $(this).addClass("change");
        $("#load_banner_con").load("productPic.html",function(){
            mySwiper.removeAllSlides();
            $("#load_banner_con a").each(function(n,i){
                mySwiper.appendSlide(i.outerHTML,'swiper-slide','div');
            });
            mySwiper.reInit();
        });
    });

    var flashvars={f:'uploads/Big_Buck_Bunny_Trailer.m4v',c:0};
    var video=['uploads/Big_Buck_Bunny_Trailer.m4v->video/m4v'];
    CKobject.embed('ckplayer/ckplayer.swf','player','ckplayer_a1','100%','100%',true,flashvars,video);
    $(".video").click(function() {
        $(".modal").show();
        $("#player").show(function(){
            CKobject.getObjectById('ckplayer_a1').videoPlay()
        });
    });

    $("#player_bg").click(function(){
        CKobject.getObjectById('ckplayer_a1').videoPause();
        $("#player").hide(function(){
            CKobject.getObjectById('ckplayer_a1').videoSeek(0);
            $(".modal").fadeOut();
        });
    });
});